/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ModelViewerJApplet.java
 *
 * Created on Dec 25, 2008, 12:11:49 PM
 */
package com.shailan.projects.modelviewer.applet;


import com.sun.opengl.util.*;
import javax.media.opengl.GLEventListener;
import javax.swing.JApplet;

public class ModelViewerJApplet extends JApplet {

    private Animator animator,animator2;
    private GLRenderer glRenderer;

    /** Initializes the applet ModelViewerJApplet */
    public void init() {
        glRenderer=new GLRenderer();
        glRenderer.obj=0;
        initComponents();
        
        gLCanvas1.addGLEventListener(glRenderer);
        animator = new FPSAnimator(gLCanvas1, 60);
        gLCanvas1.requestFocus();
    }

    public void start() {
        animator.start();
        
    }

    public void stop() {
        // FIXME: do I need to do anything else here?
        animator.stop();
        
    }
    public void setModel(int model){
        glRenderer.obj=model;
        glRenderer.loadModel();
        this.repaint();
    }

    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        gLCanvas1 = new javax.media.opengl.GLCanvas();

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(gLCanvas1, javax.swing.GroupLayout.DEFAULT_SIZE, 580, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(gLCanvas1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.media.opengl.GLCanvas gLCanvas1;
    // End of variables declaration//GEN-END:variables
}
